package com.pointi.sysChecker;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.hyperic.sigar.Mem;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException;

public class sysRAM
{
	public String getRAM() throws SigarException
	{
		Sigar sigar = new Sigar() ;
		Mem mem = sigar.getMem() ;
		SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss") ;
		String content = "" ;
		content += "(" + formatter.format(new Date()) + ") " ;
		content += "[RAM]" ;
		content += " TOTAL: " + format(mem.getTotal()/1024) ;
		content += " USED: " + format(mem.getUsed()/1024) ;
		content += " FREE: " + format(mem.getFree()/1024) ;
		return content ;
	}

	public static String format(Long value) {
		return Long.toString(new Long(value / 1024)) ;
	}

	public static void mem_output(String[] value) {
		String str = "" ;
		for(int i=0 ; i < value.length ; i++) {
			str += value[i] + "\t" ;
		}
		System.out.println(str) ;
	}
}
